
#ifndef SOCKET_AGENT_H
#define SOCKET_AGENT_H

#include "SysLib.h"

#include "Common.h"

struct _SocketWrapper {
#ifdef OS_WIN
    SOCKET fd;
    OVERLAPPED  *olRead;
    OVERLAPPED  *olWrite;
    bool reading;
    bool writing;
#else
    int fd;
#endif
};
typedef struct _SocketWrapper SocketWrapper;
typedef SocketWrapper * PSocketWrapper;

PSocketWrapper socket_new();
void socket_delete(PSocketWrapper obj);

PSocketWrapper socket_connect(const char *host, int port, bool blocking);
int socket_read(PSocketWrapper sock, PBuffer buf);
int socket_write(PSocketWrapper sock, PBuffer buf);

void socket_close(PSocketWrapper sock);

#endif
